<html>
<head><meta charset="utf-8"><title>Try operator in destructure · project-error-handling · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/index.html">project-error-handling</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Try.20operator.20in.20destructure.html">Try operator in destructure</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="231564508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Try%20operator%20in%20destructure/near/231564508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Try.20operator.20in.20destructure.html#231564508">(Mar 24 2021 at 00:24)</a>:</h4>
<p>Has there been any talk about allowing the Try (<code>?</code>) operator in a destructure position like this?</p>
<div class="codehilite"><pre><span></span><code>iter.inspect(|(_, thing)?|  { ... })
</code></pre></div>
<p>This could be quite handy when working with result-yielding iterators.</p>



<a name="231564529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Try%20operator%20in%20destructure/near/231564529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Try.20operator.20in.20destructure.html#231564529">(Mar 24 2021 at 00:24)</a>:</h4>
<p>(Maybe there is a better place to ask this?)</p>



<a name="231564532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Try%20operator%20in%20destructure/near/231564532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Try.20operator.20in.20destructure.html#231564532">(Mar 24 2021 at 00:24)</a>:</h4>
<p>not that I know of</p>



<a name="231564582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Try%20operator%20in%20destructure/near/231564582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Try.20operator.20in.20destructure.html#231564582">(Mar 24 2021 at 00:25)</a>:</h4>
<p>this is a langs team issue though, try operator and block is explicitly out of scope for this project group</p>



<a name="231564613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Try%20operator%20in%20destructure/near/231564613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Try.20operator.20in.20destructure.html#231564613">(Mar 24 2021 at 00:25)</a>:</h4>
<p>Got it, should I move this to <code>t-lang</code>?</p>



<a name="231564663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Try%20operator%20in%20destructure/near/231564663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Try.20operator.20in.20destructure.html#231564663">(Mar 24 2021 at 00:26)</a>:</h4>
<p>yea, that would probably be the best way to move this forward</p>



<a name="231587019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Try%20operator%20in%20destructure/near/231587019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Try.20operator.20in.20destructure.html#231587019">(Mar 24 2021 at 05:48)</a>:</h4>
<p><span class="user-mention" data-user-id="319552">@Jeremiah Senkpiel</span> I haven't seen any such proposals floated, even speculatively.</p>



<a name="232051497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Try%20operator%20in%20destructure/near/232051497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Try.20operator.20in.20destructure.html#232051497">(Mar 27 2021 at 01:05)</a>:</h4>
<p>The only version of this I've seen proposed was in the context of <code>for x? in iterator_of_results</code>.</p>
<p>The inspect one seems surprising to me since I'm not sure what type signature it's expected to provide.  The <code>for</code> version was something like desugaring <code>for x? in ... {</code> to <code>for x in ... { let x = x?;</code> (IIRC), but I'm not sure how to do that in a <code>-&gt; ()</code> method like <code>inspect</code>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>